package com.loyi.ams.gateway.hbmis.rest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.lang3.ArrayUtils;
import org.codehaus.jackson.map.ser.ArraySerializers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.loyi.ams.gateway.hbmis.dao.IDeviceDAO;
import com.loyi.cloud.hbmis.api.IDeviceService;
import com.loyi.cloud.hbmis.domain.Device;
import com.mysql.fabric.xmlrpc.base.Array;

@RestController
@RequestMapping("device")
public class DeviceService implements IDeviceService {

	@Autowired
	private IDeviceDAO deviceDAO;

	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@RequestMapping("find")
	public List<Device> find(@RequestParam(value = "ptid", required = false) String ptid,
			@RequestParam(value = "deviceid", required = false) String deviceid,
			@RequestParam(value = "state", required = false) List<Integer> state,
			@RequestParam(value = "protocol", required = false) List<Integer> protocol) {
		return deviceDAO.findAll(ptid, deviceid, state, protocol);
	}
}
